package com.gitee.wsl.mathematics.vector.ext

import com.gitee.wsl.mathematics.vector.Vector

fun<T:Number,V: Vector<T, V>> V.every(block:(T)->Boolean) = proxy.any(block)

fun<T:Number,V: Vector<T, V>> V.nth(idx: Int) = proxy[idx]

/**
 * 判断两个向量是否正交
 */
fun<T:Number,V: Vector<T, V>> V.isOrthogonalTo(other: Vector<T,*>) = (this dot other) == .0

fun<T:Number,V: Vector<T, V>> V.isNotOrthogonalTo(other: Vector<T,*>) = (this dot other) != .0


/**
 * 判断两个向量是否平行
 */
fun<T:Number,V: Vector<T, V>> V.isParallelTo(other: Vector<T,*>) = (this dot other) / length / other.length == one

fun<T:Number,V: Vector<T, V>> V.isNotParallelTo(other: Vector<T,*>) = (this dot other) / length / other.length != one
